//
//  RequestData.m
//  AAIM
//
//  Created by 远的小布丁 on 2019/12/12.
//  Copyright © 2019 AAIM. All rights reserved.
//

#import "RequestData.h"

//个人中心
#define UserCenterData @"/user/mine"
//省市
#define ProvincesCity @"/user/city"
//个人信息
#define UserInfoData @"/user/userInfo"

//修改信息
#define ChangeUserInfo @"/user/userUpdate"

//修复密码
#define ChangePassword @"/user/upPwd"
//用户设置发现口令
#define FindCode @"/user/findCode"
//发现接口
#define DiscoverUrl @"/common/findUrl"


//公众号
//用户公众号列表
#define Public_user_list @"/public/userList"
//关注
#define Public_user_attention @"/public/focus"
//公众号i信息
#define Public_info @"/public/publicDetail"
//公众号二维码
#define Public_QRCode @"/public/qrCode"
//公众号菜单列表
#define Public_menus @"/public/menus"
//公众号菜单内容
#define Public_menuDetail @"/public/menuDetail"

//账单
//账单列表
#define Bill_List @"/bill/list"
//账单保存
#define Bill_Save @"/bill/save"

@implementation RequestData

+(void)GetUserCenterDataWithToken:(NSString *)token userUUid:(NSString *)uuid Success:(void (^)(NSDictionary * _Nonnull))success failure:(void (^)(NSString * _Nonnull))failure
{
    NSMutableDictionary * paramentdic =[[NSMutableDictionary alloc]init];
    [paramentdic setValue:token forKey:@"t"];
    [paramentdic setValue:uuid forKey:@"uuid"];
    
    [[NetWorkTool shareInstance]requestWithPath:UserCenterData method:HttpRequestPost paramenters:paramentdic completion:^(SLResultModel * _Nonnull res) {
        NSLog(@"个人中心数据：%@",res);
        if (res.isSuccess) {

            success(res.rawdata);

        }else
        {
            failure(res.message);
        }

    }];

}

+(void)GetProvincesAndCitiesWithToken:(NSString *)token userUUid:(NSString *)uuid Success:(void (^)(NSDictionary * _Nonnull))success failure:(void (^)(NSString * _Nonnull))failure{
    NSMutableDictionary * paramentdic =[[NSMutableDictionary alloc]init];
       [paramentdic setValue:token forKey:@"t"];
       [paramentdic setValue:uuid forKey:@"uuid"];
       
       [[NetWorkTool shareInstance]requestWithPath:ProvincesCity method:HttpRequestPost paramenters:paramentdic completion:^(SLResultModel * _Nonnull res) {
           NSLog(@"省市：%@",res);
           if (res.isSuccess) {

               success(res.rawdata);

           }else
           {
               failure(res.message);
           }

       }];
}

+ (void)GetUserInfoWithToken:(NSString *)token userUUid:(NSString *)uuid fuuid:(NSString *)fuuid Success:(void (^)(NSDictionary * _Nonnull))success failure:(void (^)(NSString * _Nonnull))failure{
    
    NSMutableDictionary * parameDic = [NSMutableDictionary dictionary];

    [parameDic setValue:token forKey:@"t"];
    [parameDic setValue:uuid forKey:@"uuid"];
    [parameDic setValue:fuuid forKey:@"fuuid"];
    
    [[NetWorkTool shareInstance] requestWithPath:UserInfoData method:HttpRequestPost paramenters:parameDic completion:^(SLResultModel * _Nonnull res) {
        
        if (res.isSuccess) {
            success(res.rawdata);
        }else{
            failure(res.message);
        }
    }];
}

+ (void)changeUserInfoWithToken:(NSString *)token userUUid:(NSString *)uuid areaStr:(NSString *)area withBirthday:(NSString *)birthday withCity:(NSString *)city withCompany:(NSString *)company withHead:(NSString *)head withIsVerify:(NSString *)isVerify withJob:(NSString *)job withNickName:(NSString *)nickname withProvince:(NSString *)province withRemark:(NSString *)remark withSex:(NSString *)sex Success:(void (^)(NSDictionary * _Nonnull))success failure:(void (^)(NSString * _Nonnull))failure{
    
    NSMutableDictionary * parameDic = [NSMutableDictionary dictionary];

    [parameDic setValue:token forKey:@"t"];
    [parameDic setValue:uuid forKey:@"uuid"];
    [parameDic setValue:area forKey:@"area"];
    if (birthday && ![birthday isEqualToString:@""]) {
        [parameDic setValue:birthday forKey:@"birthday"];
    }
    if (company &&![company isEqualToString:@""]) {
     [parameDic setValue:company forKey:@"company"];
    }
    
    
    if (head && ![head isEqualToString:@""]) {
        [parameDic setValue:head forKey:@"head"];
    }
    [parameDic setValue:isVerify forKey:@"isVerify"];
    if (job&&![job isEqualToString:@""]) {
        [parameDic setValue:job forKey:@"job"];
    }
    if (nickname &&![nickname isEqualToString:@""]) {
        [parameDic setValue:nickname forKey:@"nickname"];
    }
    if (province &&![[NSString stringWithFormat:@"%@",province] isEqualToString:@""]) {
       [parameDic setValue:province forKey:@"province"];
       
    }
    if (city&&![[NSString stringWithFormat:@"%@",city] isEqualToString:@""]) {
        [parameDic setValue:city forKey:@"city"];
    }
   
    if(remark &&![remark isEqualToString:@""]){
     [parameDic setValue:remark forKey:@"remark"];
    }
    if (sex &&![sex isEqualToString:@""]) {
     [parameDic setValue:sex forKey:@"sex"];
    }
    
    
    [[NetWorkTool shareInstance] requestWithPath:ChangeUserInfo method:HttpRequestPost paramenters:parameDic completion:^(SLResultModel * _Nonnull res) {
        
        if (res.isSuccess) {
            success(res.rawdata);
        }else{
            failure(res.message);
        }
    }];
}

+ (void)changePasswordWithToken:(NSString *)token userUUid:(NSString *)uuid withNewPwd:(NSString *)newPwd withOldPwd:(NSString *)oldPwd withType:(NSString *)type Success:(void (^)(NSDictionary * _Nonnull))success failure:(void (^)(NSString * _Nonnull))failure{
    
    NSMutableDictionary * parameDic = [NSMutableDictionary dictionary];

       [parameDic setValue:token forKey:@"t"];
       [parameDic setValue:uuid forKey:@"uuid"];
       [parameDic setValue:newPwd forKey:@"newPwd"];
       [parameDic setValue:oldPwd forKey:@"oldPwd"];
    if ([type isEqualToString:@"loginPwd"]) {
        [parameDic setValue:@"l" forKey:@"type"];
    }else{
        [parameDic setValue:@"p" forKey:@"type"];
    }
       
       
       [[NetWorkTool shareInstance] requestWithPath:ChangePassword method:HttpRequestPost paramenters:parameDic completion:^(SLResultModel * _Nonnull res) {
           
           if (res.isSuccess) {
               success(res.rawdata);
           }else{
               failure(res.message);
           }
       }];
//    requestGroupAuthListWithGroupid
}

+ (void)PostWithToken:(NSString *)token userUUid:(NSString *)uuid withCode:(NSString *)code Success:(void (^)(NSDictionary * _Nonnull))success failure:(void (^)(NSString * _Nonnull))failure{
    
       NSMutableDictionary * parameDic = [NSMutableDictionary dictionary];

          [parameDic setValue:token forKey:@"t"];
          [parameDic setValue:uuid forKey:@"uuid"];
          [parameDic setValue:code forKey:@"code"];
  
          
          
          [[NetWorkTool shareInstance] requestWithPath:FindCode method:HttpRequestPost paramenters:parameDic completion:^(SLResultModel * _Nonnull res) {
              
              if (res.isSuccess) {
                  success(res.rawdata);
              }else{
                  failure(res.message);
              }
          }];
    
}

+ (void)PostDiscoverWithToken:(NSString *)token userUUid:(NSString *)uuid Success:(void (^)(NSDictionary * _Nonnull))success failure:(void (^)(NSString * _Nonnull))failure{

         NSMutableDictionary * parameDic = [NSMutableDictionary dictionary];

            [parameDic setValue:token forKey:@"t"];
            [parameDic setValue:uuid forKey:@"uuid"];
    
            
            
            [[NetWorkTool shareInstance] requestWithPath:DiscoverUrl method:HttpRequestPost paramenters:parameDic completion:^(SLResultModel * _Nonnull res) {
                
                if (res.isSuccess) {
                    success(res.rawdata);
                }else{
                    failure(res.message);
                }
            }];
}


//公众号
+(void)PostPublicWithToken:(NSString *)token userUUid:(NSString *)uuid Success:(void (^)(NSDictionary * _Nonnull))success failure:(void (^)(NSString * _Nonnull))failure{
    NSMutableDictionary * parameDic = [NSMutableDictionary dictionary];

            [parameDic setValue:token forKey:@"t"];
            [parameDic setValue:uuid forKey:@"uuid"];
    
            
            
    [[NetWorkTool shareInstance] requestPublicWithPath:Public_user_list method:HttpRequestPost paramenters:parameDic completion:^(SLResultModel * _Nonnull res) {

                if (res.isSuccess) {
                    success(res.rawdata);
                }else{
                    failure(res.message);
                }
            }];
    
}

+(void)PostAttentionPublicWithToken:(NSString *)token publicUdid:(NSString *)udid withUserUuid:(NSString *)uuid withIsAdd:(NSString *)isadd withFuuid:(NSString *)fuuid Success:(void (^)(NSDictionary * _Nonnull))success failure:(void (^)(NSString * _Nonnull))failure{
    NSMutableDictionary * parameDic = [NSMutableDictionary dictionary];
    
    [parameDic setValue:token forKey:@"t"];
    [parameDic setValue:uuid forKey:@"uuid"];
    [parameDic setValue:udid forKey:@"udid"];
    [parameDic setValue:isadd forKey:@"isadd"];
    if (fuuid &&![CommonTools isEmpty:fuuid]) {
        [parameDic setValue:fuuid forKey:@"fuuid"];
    }
    
    
       [[NetWorkTool shareInstance] requestPublicWithPath:Public_user_attention method:HttpRequestPost paramenters:parameDic completion:^(SLResultModel * _Nonnull res) {

                   if (res.isSuccess) {
                       success(res.rawdata);
                   }else{
                       failure(res.message);
                   }
               }];
}

+ (void)PostPublicInfoWithToken:(NSString *)token userUUid:(NSString *)uuid withPublicUDID:(NSString *)udid Success:(void (^)(NSDictionary * _Nonnull))success failure:(void (^)(NSString * _Nonnull))failure{
    NSMutableDictionary * parameDic = [NSMutableDictionary dictionary];
    [parameDic setValue:token forKey:@"t"];
    [parameDic setValue:uuid forKey:@"uuid"];
    [parameDic setValue:udid forKey:@"udid"];
    
       [[NetWorkTool shareInstance] requestPublicWithPath:Public_info method:HttpRequestPost paramenters:parameDic completion:^(SLResultModel * _Nonnull res) {

                   if (res.isSuccess) {
                       success(res.rawdata);
                   }else{
                       failure(res.message);
                   }
               }];
}

+ (void)PostPublicQRCodeWithToken:(NSString *)token userUUid:(NSString *)uuid withPublicUDID:(NSString *)udid Success:(void (^)(NSDictionary * _Nonnull))success failure:(void (^)(NSString * _Nonnull))failure{
    NSMutableDictionary * parameDic = [NSMutableDictionary dictionary];
    [parameDic setValue:token forKey:@"t"];
    [parameDic setValue:uuid forKey:@"uuid"];
    [parameDic setValue:udid forKey:@"udid"];
    
       [[NetWorkTool shareInstance] requestPublicWithPath:Public_QRCode method:HttpRequestPost paramenters:parameDic completion:^(SLResultModel * _Nonnull res) {

                   if (res.isSuccess) {
                       success(res.rawdata);
                   }else{
                       failure(res.message);
                   }
               }];
}

+(void)PostPublicMenuListWithToken:(NSString *)token userUUid:(NSString *)uuid withPublicUDID:(NSString *)udid Success:(void (^)(NSDictionary * _Nonnull))success failure:(void (^)(NSString * _Nonnull))failure{
    NSMutableDictionary * parameDic = [NSMutableDictionary dictionary];
       [parameDic setValue:token forKey:@"t"];
       [parameDic setValue:uuid forKey:@"uuid"];
       [parameDic setValue:udid forKey:@"udid"];
       
          [[NetWorkTool shareInstance] requestPublicWithPath:Public_menus method:HttpRequestPost paramenters:parameDic completion:^(SLResultModel * _Nonnull res) {

                      if (res.isSuccess) {
                          success(res.rawdata);
                      }else{
                          failure(res.message);
                      }
                  }];
}

+ (void)PostPublicMenuInfoWithToken:(NSString *)token userUUid:(NSString *)uuid withPublicID:(NSString *)ID Success:(void (^)(NSDictionary * _Nonnull))success failure:(void (^)(NSString * _Nonnull))failure{
    NSMutableDictionary * parameDic = [NSMutableDictionary dictionary];
       [parameDic setValue:token forKey:@"t"];
       [parameDic setValue:uuid forKey:@"uuid"];
       [parameDic setValue:ID forKey:@"id"];
       
          [[NetWorkTool shareInstance] requestPublicWithPath:Public_menuDetail method:HttpRequestPost paramenters:parameDic completion:^(SLResultModel * _Nonnull res) {

                      if (res.isSuccess) {
                          success(res.rawdata);
                      }else{
                          failure(res.message);
                      }
                  }];
}

+ (void)PostBillListWithToken:(NSString *)token userUUid:(NSString *)uuid withPage:(NSInteger)page withUdid:(NSString *)udid Success:(void (^)(NSDictionary * _Nonnull))success failure:(void (^)(NSString * _Nonnull))failure{
    NSMutableDictionary * parameDic = [NSMutableDictionary dictionary];
       [parameDic setValue:token forKey:@"t"];
       [parameDic setValue:uuid forKey:@"uuid"];
    if (udid&&![CommonTools isEmpty:udid]) {
        [parameDic setValue:udid forKey:@"udid"];
    }
       
            [[NetWorkTool shareInstance] requestWithPath:Bill_List method:HttpRequestPost paramenters:parameDic completion:^(SLResultModel * _Nonnull res) {

                      if (res.isSuccess) {
                          success(res.rawdata);
                      }else{
                          failure(res.message);
                      }
                  }];
}

+ (void)PostBillListWithCreateTime:(NSString *)createTime userDescribe:(NSString *)describe withFuuid:(NSString *)fuuid withOrderid:(NSString *)orderid withParameter:(NSString *)parameter withRemark:(NSString *)remark withTitle:(NSString *)title withUrl:(NSString *)url Success:(void (^)(NSDictionary * _Nonnull))success failure:(void (^)(NSString * _Nonnull))failure{
    NSMutableDictionary * parameDic = [NSMutableDictionary dictionary];
    [parameDic setValue:createTime forKey:@"createTime"];
    [parameDic setValue:describe forKey:@"describe"];
    [parameDic setValue:fuuid forKey:@"fuuid"];
    [parameDic setValue:orderid forKey:@"orderid"];
    [parameDic setValue:parameter forKey:@"parameter"];
    [parameDic setValue:remark forKey:@"remark"];
    [parameDic setValue:title forKey:@"title"];
    [parameDic setValue:url forKey:@"url"];
       
    [[NetWorkTool shareInstance] requestWithPath:Bill_Save method:HttpRequestPost paramenters:parameDic completion:^(SLResultModel * _Nonnull res) {
        
        if (res.isSuccess) {
            success(res.rawdata);
        }else{
            failure(res.message);
        }
    }];
}
@end
